<template>
    <div>
    <el-card>
        <h1>这是子组件</h1>
        <el-alert :title="msg" />
        <el-input v-model="childMsg"></el-input>
        <hr>
        <el-button type="primary" @click="$emit('childClick','来自子组件的点击')">来自子组件的点击</el-button>
        <el-button type="primary" @click="sendMsg">发送Child子组件消息</el-button>
    </el-card>
    </div>
</template>

<script>
import { ref} from 'vue';
import bus from 'vue3-eventbus';

export default {
    name: 'Child',
    props: {
        msg: String
    },
    setup() {
        const childMsg=ref("我是子组件的值")
        const sendMsg=function(){
            bus.emit("getMsg",childMsg)
        }
        return {
            childMsg
        }
    }
}

</script>

<style></style>